//
//  PublicityListCellModel.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/11/26.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "PublicityListCellModel.h"

#import "ArticleListData.h"

@interface PublicityListCellModel ()

@property (nonatomic, copy) NSString* content;
@property (nonatomic, copy) NSString* addr;
@property (nonatomic, copy) NSString* time;
@property (nonatomic, strong) RACCommand* moreCmd;

@end

@implementation PublicityListCellModel

- (instancetype)initWithData:(id)data cellHeight:(CGFloat)cellHeight
{
    self = [super init];
    if (self)
    {
        _data = data;
        
        /// cellHeight+2（2容错）
        _cellHeight = MHUIScaleValue(cellHeight)+2;
        
        @weakify(self);
        [[RACObserve(self, data) distinctUntilChanged] subscribeNext:^(id x)
         {
             @strongify(self);
             
             ArticleListData* curAListData = x;
             
             self.content = curAListData.title;
             self.addr = HCStrFormat(@"项目地址：%@", curAListData.areaName);
             self.time = curAListData.addTime;
             
             self.moreCmd = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input)
                             {
                                 return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber)
                                         {
                                             [subscriber sendNext:nil];
                                             [subscriber sendCompleted];
                                             
                                             return nil;
                                         }];
                             }];
         }];
    }
    
    return self;
}

@end
